﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using System.Xml;

namespace xaml_serialization
{
    class Program
    {
        static void Main(string[] args)
        {
            var tw = new StreamWriter("x.xaml");
            var xw = new XmlTextWriter(tw);
            var s = new XamlDesignerSerializationManager(xw);

            var r = new FunctionalUnit {Name = "root"};
            r.Subunits.Add(new FunctionalUnit { Name = "sub1" });
            r.Subunits.Add(new FunctionalUnit { Name = "sub2" });

            XamlWriter.Save(r, s);
        }
    }

    public class FunctionalUnit
    {
        public string Name { get; set; }
        public List<FunctionalUnit> Subunits { get; set; }

        public FunctionalUnit()
        {
            this.Subunits = new List<FunctionalUnit>();
        }
    }
}
